<div>
<div class="float-left">杯赛名称</div>
<div class="float-left" style="width : 400px; margin : 0 0 0 200px"><?php echo $this->cup->name?></div>
</div>


<div style="clear : both; margin : 50px 0 0 0">
<div class="group-stage">淘汰赛 </div>

</div>
<div id="knock-out-stage-form">
<form action="/admin/save-cup-ko-team-vs/cup-id/<?php echo $this->cup->id?>" method ="post">
<div style="clear : both">

<?php 
$round = 1;
$count = 1;
$teams = $this->teams;

$team_count = $this->cup->team_count;
while($team_count!=1){
?>
<div class="group-name" style="font-size:20px">第<?php echo $round ; ?>轮</div>
<?php
   for($i=0;$i<floor($team_count/2);$i++){
?>

	<?php if(empty($teams[$count])){?>
	<div class="table-cup-away-team-user-choose float-left" style="clear: both; margin : 20px;cursor:pointer">
	    选择
	</div>
	<?php }else{ ?>
	<div class="table-cup-away-team-user-delete float-left" style="clear: both; margin : 20px; cursor:pointer" >
	   删除
	</div>
	<?php } ?>

	<div class="table-cup-team" style="clear : none; margin : 20px 0 0 10px;">
		<input type="text" name="away_team_<?php echo $count ;?>" id="away_team_<?php echo $count ;?>" value="<?php echo 
		isset($teams[$count])?$teams[$count]['away_team_name']:'';?>" size="20" readonly="readonly"/>
	</div>
	<div style="float : left;margin : 20px;"> VS </div>
	<div class="table-cup-team" style="margin : 20px 0 0 10px; clear : none;">
		<input type="text" name="home_team_<?php echo $count ;?>" id="home_team_<?php echo $count ;?>" value="<?php echo 
		isset($teams[$count])?$teams[$count]['home_team_name']:'';?>" size="20" readonly="readonly"/>
	</div>
	<?php if(empty($teams[$count])){?>
   <div class="table-cup-home-team-user-choose float-left " style="margin : 20px; cursor:pointer">
	    选择
	</div>
	<?php }else{ ?>
	<div class="table-cup-home-team-user-delete float-left" style="margin : 20px; cursor:pointer">
	   删除
	</div>
	<?php } 
 
      $count++;}
	  
	  $team_count = ceil($team_count/2);
	 $round++;
	}?>


</div>
<div style="clear : both;padding : 50px 0 0 200px;">
<input id="" class="button" type="submit" value="    确定    " />
</div>
<input type="hidden" id="cible-group" value="group-stage" name="cible">
</form>

</div>

<div id="user-input-dialog">
      no display 
</div>





<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.fn.center = function () {

	
	var top_height = ( $(window).height()-this.height() ) / 2+$(window).scrollTop();
	if(top_height<0){
		top_height=0;
	}

	this.css("top", top_height + "px");

	this.css("left", ( $(window).width()-this.width() ) / 2+$(window).scrollLeft() + "px");

	return this;

	}


	
$(document).ready(function() {

    $(".table-cup-away-team-user-choose").each(function(){                 
  	  $(this).click(function(){
      	  $(this).addClass('chosen');

      	  var user_names=new Array(<?php echo $this->all_team_names;?>); 		      
			  
				      
			  var all_user_ids = new Array(<?php echo $this->all_team_ids?>);				       
            var html_text = "";
            var first = true;
            var nb = 1;
            for(var name in user_names){                                   	
				
							   if(first){
								    first=false;
                          	   		html_text += '<div class="user-radio-left"><input type="radio" name="user_ids" value = "' 
                              	             + user_names[name]  + '">' + user_names[name] +'</div>' ;
							   }else{
								   first=true;
								   html_text += '<div class="user-radio-right"><input type="radio" name="user_ids" value = "' 
                      	             + user_names[name]  + '">' + user_names[name] +'</div>' ;
							   }
							   if(nb++ == 10){
								   html_text +='<div style="clear : both; height: 40px" />';
								   nb = 1;
							   }
							   
						  
               
                      }

  				    if(html_text==""){
      				    html_text= "对不起，没有可分配的球队"
     				    	 + '</div><div style="float: right;margin :20px 20px 20px 90px"><INPUT TYPE=BUTTON OnClick="chooseTeam()" VALUE="关闭" ></div>'
				              ;
  				    }else{
      				    
      				    html_text += '<div class="choose-user-button" ><INPUT TYPE=BUTTON OnClick="chooseTeam(' 
          				              + "'" +$('.chosen').next().find('input').attr('id') + "'" 
          				              + ');" VALUE="选择" >'
          				              + '</div><div style="float: left;margin :20px 20px 20px 90px"><INPUT TYPE=BUTTON OnClick="chooseTeam()" VALUE="关闭" ></div>'
          				              ;
  				    }
  				    $('#user-input-dialog').html(html_text);
  				    $('.chosen').removeClass('chosen');
  				 
      	  
  		  $('#user-input-dialog').fadeIn();

    	  $(".user-radio-left:even").addClass("bg-gray"); 
    	  $(".user-radio-right:odd").addClass("bg-gray"); 
  		$('#user-input-dialog').center();
        })
    });
	
	
	
	
	$(".table-cup-home-team-user-choose").each(function(){                 
  	  $(this).click(function(){
      	  $(this).addClass('chosen');

      	  var user_names=new Array(<?php echo $this->all_team_names;?>); 		      
			 
				      
			  var all_user_ids = new Array(<?php echo $this->all_team_ids?>);				       
            var html_text = "";
            var first = true;
            var nb = 1;
            for(var name in user_names){                                   	
				
							   if(first){
								    first=false;
                          	   		html_text += '<div class="user-radio-left"><input type="radio" name="user_ids" value = "' 
                              	             + user_names[name]  + '">' + user_names[name] +'</div>' ;
							   }else{
								   first=true;
								   html_text += '<div class="user-radio-right"><input type="radio" name="user_ids" value = "' 
                      	             + user_names[name]  + '">' + user_names[name] +'</div>' ;
							   }
							   if(nb++ == 10){
								   html_text +='<div style="clear : both; height: 40px" />';
								   nb = 1;
							   }
							   
						   
               
                      }

  				    if(html_text==""){
      				    html_text= "对不起，没有可分配的球队"
     				    	 + '</div><div style="float: right;margin :20px 20px 20px 90px"><INPUT TYPE=BUTTON OnClick="chooseTeam()" VALUE="关闭" ></div>'
				              ;
  				    }else{
      				    
      				    html_text += '<div class="choose-user-button" ><INPUT TYPE=BUTTON OnClick="chooseTeam(' 
          				              + "'" +$('.chosen').prev().find('input').attr('id') + "'" 
          				              + ');" VALUE="选择" >'
          				              + '</div><div style="float: left;margin :20px 20px 20px 90px"><INPUT TYPE=BUTTON OnClick="chooseTeam()" VALUE="关闭" ></div>'
          				              ;
  				    }
  				    $('#user-input-dialog').html(html_text);
  				    $('.chosen').removeClass('chosen');
  				 
      	  
  		  $('#user-input-dialog').fadeIn();

    	  $(".user-radio-left:even").addClass("bg-gray"); 
    	  $(".user-radio-right:odd").addClass("bg-gray"); 
  		$('#user-input-dialog').center();
        })
    });


	
	$(".table-cup-away-team-user-delete").each(function(){                 
  	  $(this).click(function(){ 
      	  $(this).addClass('chosen');          
			$('.chosen').next().find('input').attr('value','');
  			$('.chosen').removeClass('chosen'); 		  
        })
    });
	
	$(".table-cup-home-team-user-delete").each(function(){                 
  	  $(this).click(function(){
      	  $(this).addClass('chosen');          
			$('.chosen').prev().find('input').attr('value','');
  			$('.chosen').removeClass('chosen'); 		  
        })
    });
 


});

function chooseTeam( id){
	var item = $(":radio:checked"); 
	var len=item.length; 
	if(len>0){ 	
		//alert($(":radio:checked").html()) ;
	  $('#' +id +'').attr('value',$(":radio:checked").val()); 
	  
	} 
	$('#user-input-dialog').hide();
	//$('.bModal').hide();

	//$('.bModal').attr('style','');

};


function close( ){
	
	$('#user-input-dialog').hide();
	

};





//--><!]]>
</script>
